from __future__ import division
import numpy

tblocks = [0.1, 0.13, 0.15, 0.23, 0.25, 0.4, 0.44, 0.65, 0.76, 0.78, 0.81]

def blocks(N):
	tvals = tblocks
	hvals = [4.0, -5.0, 3.0, -4.0, 5.0, -4.2, 2.1, 4.3, -3.1, 2.1, -4.2]
	P = len(tvals)

	def K(s): return (1 + numpy.sign(s))/2
	def f(s): return 3.65948*sum([(hvals[j]*K(s - tvals[j])) for j in range(P)])

	vals = [f(i/N) for i in range(N)]
	return numpy.array(vals,numpy.float)


def bumps(N):
	tvals = tblocks
	hvals = [4.0,5.0,3.0,4.0,5.0,4.2,2.1,4.3,3.1,5.1,4.2]
	wvals = [0.005,0.005,0.006,0.01,0.01,0.03,0.01,0.01,0.005,0.008,0.005]
	P = len(tvals)

	def K(s): return 1.0/(1.0 + abs(s))**4.0
	def f(s): return 10.5174*sum([hvals[j]*K((s-tvals[j])/wvals[j])
					for j in range(P)])

	vals = [f(i/N) for i in range(N)]
	return numpy.array(vals,numpy.float)

	
def heavisine(N):
	def f(s):
		val = 4.0*numpy.sin(4.0*numpy.pi*s)
		return val - numpy.sign(s - 0.3) - numpy.sign(0.72 - s)

	vals = [f(i/N) for i in range(N)]
	return numpy.array(vals,numpy.float)
		

def doppler(N):
	def f(s):
		val = numpy.sqrt(s*(1.0 - s))
		return val*numpy.sin(2.0*numpy.pi*1.05/(s + 0.05))

	vals = [f(i/N) for i in range(N)]
	return numpy.array(vals,numpy.float)
